import React, { Component } from 'react';
import { TabBar } from 'antd-mobile'

// 引入图片
import cookbook from '@/assets/image/cookbook.png'
import cookbookActive from '@/assets/image/cookbook-active.png'
import menu from '@/assets/image/menu.png'
import menuActive from '@/assets/image/menu-active.png'
import more from '@/assets/image/more.png'
import moreActive from '@/assets/image/more-active.png'

// 首页
import Cookbook from '../../views/cookbook/index';
import Cate from '@/views/cate/index';
import More from '@/views/more/index'

class index extends Component {
  state = {
    selectedTab: 'more',
    // 让底部导航条显示还是隐藏，日后存放到redux中
    hidden: false,
  };
  render() {
    return (
      <div style={{ position: 'fixed', height: '100%', width: '100%', top: 0 }}>
        <TabBar
          unselectedTintColor="#949494"
          tintColor="#000"
          barTintColor="white"
          hidden={this.state.hidden}
        >
          <TabBar.Item
            title="菜谱大全"
            key="cookbook"
            icon={<div style={{
              width: '22px',
              height: '22px',
              background: `url(${cookbook}) center center /  21px 21px no-repeat`
            }}
            />
            }
            selectedIcon={<div style={{
              width: '22px',
              height: '22px',
              background: `url(${cookbookActive}) center center /  21px 21px no-repeat`
            }}
            />
            }
            selected={this.state.selectedTab === 'cookbook'}
            // badge={1}
            onPress={() => {
              this.setState({
                selectedTab: 'cookbook',
              });
            }}
            data-seed="logId"
          >
            <Cookbook />
          </TabBar.Item>
          <TabBar.Item
            icon={
              <div style={{
                width: '22px',
                height: '22px',
                background: `url(${menu}) center center /  21px 21px no-repeat`
              }}
              />
            }
            selectedIcon={
              <div style={{
                width: '22px',
                height: '22px',
                background: `url(${menuActive}) center center /  21px 21px no-repeat`
              }}
              />
            }
            title="分类"
            key="menu"
            // badge={'new'}
            selected={this.state.selectedTab === 'menu'}
            onPress={() => {
              this.setState({
                selectedTab: 'menu',
              });
            }}
            data-seed="logId1"
          >
            <Cate />
          </TabBar.Item>
          <TabBar.Item
            icon={
              <div style={{
                width: '22px',
                height: '22px',
                background: `url(${more}) center center /  21px 21px no-repeat`
              }}
              />
            }
            selectedIcon={
              <div style={{
                width: '22px',
                height: '22px',
                background: `url(${moreActive}) center center /  21px 21px no-repeat`
              }}
              />
            }
            title="更多"
            key="more"
            // dot
            selected={this.state.selectedTab === 'more'}
            onPress={() => {
              this.setState({
                selectedTab: 'more',
              });
            }}
          >
            <More />
          </TabBar.Item>
        </TabBar>
      </div>
    );
  }
}

export default index;
